home *** CD-ROM | disk | FTP | other *** search
/ Computer Arts: Pro Software Skills - Photoshop / Computer Arts Pro Software Skills Photoshop.iso / pc / main.swf / scripts / __Packages / mx / video / CuePointManager.as next >
Encoding:
Text File  |  2011-06-06  |  26.8 KB  |  834 lines

  1. class mx.video.CuePointManager
  2. {
  3.    var _owner;
  4.    var _id;
  5.    var _asCuePointTolerance;
  6.    var _linearSearchTolerance;
  7.    var _metadataLoaded;
  8.    var allCuePoints;
  9.    var asCuePoints;
  10.    var _disabledCuePoints;
  11.    var flvCuePoints;
  12.    var navCuePoints;
  13.    var eventCuePoints;
  14.    var _asCuePointIndex;
  15.    var _disabledCuePointsByNameOnly;
  16.    static var DEFAULT_LINEAR_SEARCH_TOLERANCE = 50;
  17.    static var cuePointsReplace = [""","\"","'","\'",",",",","&","&"];
  18.    function CuePointManager(owner, id)
  19.    {
  20.       this._owner = owner;
  21.       this._id = id;
  22.       this.reset();
  23.       this._asCuePointTolerance = this._owner.getVideoPlayer(this._id).playheadUpdateInterval / 2000;
  24.       this._linearSearchTolerance = mx.video.CuePointManager.DEFAULT_LINEAR_SEARCH_TOLERANCE;
  25.    }
  26.    function reset()
  27.    {
  28.       this._metadataLoaded = false;
  29.       this.allCuePoints = null;
  30.       this.asCuePoints = null;
  31.       this._disabledCuePoints = null;
  32.       this.flvCuePoints = null;
  33.       this.navCuePoints = null;
  34.       this.eventCuePoints = null;
  35.       this._asCuePointIndex = 0;
  36.    }
  37.    function get metadataLoaded()
  38.    {
  39.       return this._metadataLoaded;
  40.    }
  41.    function set playheadUpdateInterval(aTime)
  42.    {
  43.       this._asCuePointTolerance = aTime / 2000;
  44.    }
  45.    function get id()
  46.    {
  47.       return this._id;
  48.    }
  49.    function addASCuePoint(timeOrCuePoint, name, parameters)
  50.    {
  51.       var _loc3_ = undefined;
  52.       if(typeof timeOrCuePoint == "object")
  53.       {
  54.          _loc3_ = mx.video.CuePointManager.deepCopyObject(timeOrCuePoint);
  55.       }
  56.       else
  57.       {
  58.          _loc3_ = {time:timeOrCuePoint,name:name,parameters:mx.video.CuePointManager.deepCopyObject(parameters)};
  59.       }
  60.       var _loc7_ = isNaN(_loc3_.time) || _loc3_.time < 0;
  61.       if(_loc7_)
  62.       {
  63.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  64.       }
  65.       var _loc6_ = _loc3_.name == null;
  66.       if(_loc6_)
  67.       {
  68.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be undefined or null");
  69.       }
  70.       var _loc2_ = undefined;
  71.       _loc3_.type = "actionscript";
  72.       if(this.asCuePoints == null || this.asCuePoints.length < 1)
  73.       {
  74.          _loc2_ = 0;
  75.          this.asCuePoints = new Array();
  76.          this.asCuePoints.push(_loc3_);
  77.       }
  78.       else
  79.       {
  80.          _loc2_ = this.getCuePointIndex(this.asCuePoints,true,_loc3_.time);
  81.          _loc2_ = this.asCuePoints[_loc2_].time <= _loc3_.time ? _loc2_ + 1 : 0;
  82.          this.asCuePoints.splice(_loc2_,0,_loc3_);
  83.       }
  84.       if(this.allCuePoints == null || this.allCuePoints.length < 1)
  85.       {
  86.          _loc2_ = 0;
  87.          this.allCuePoints = new Array();
  88.          this.allCuePoints.push(_loc3_);
  89.       }
  90.       else
  91.       {
  92.          _loc2_ = this.getCuePointIndex(this.allCuePoints,true,_loc3_.time);
  93.          _loc2_ = this.allCuePoints[_loc2_].time <= _loc3_.time ? _loc2_ + 1 : 0;
  94.          this.allCuePoints.splice(_loc2_,0,_loc3_);
  95.       }
  96.       var _loc5_ = this._owner.getVideoPlayer(this._id).playheadTime;
  97.       if(_loc5_ > 0)
  98.       {
  99.          if(this._asCuePointIndex == _loc2_)
  100.          {
  101.             if(_loc5_ > this.asCuePoints[_loc2_].time)
  102.             {
  103.                this._asCuePointIndex = this._asCuePointIndex + 1;
  104.             }
  105.          }
  106.          else if(this._asCuePointIndex > _loc2_)
  107.          {
  108.             this._asCuePointIndex = this._asCuePointIndex + 1;
  109.          }
  110.       }
  111.       else
  112.       {
  113.          this._asCuePointIndex = 0;
  114.       }
  115.       var _loc4_ = mx.video.CuePointManager.deepCopyObject(this.asCuePoints[_loc2_]);
  116.       _loc4_.array = this.asCuePoints;
  117.       _loc4_.index = _loc2_;
  118.       return _loc4_;
  119.    }
  120.    function removeASCuePoint(timeNameOrCuePoint)
  121.    {
  122.       if(this.asCuePoints == null || this.asCuePoints.length < 1)
  123.       {
  124.          return null;
  125.       }
  126.       var _loc2_ = undefined;
  127.       switch(typeof timeNameOrCuePoint)
  128.       {
  129.          case "string":
  130.             _loc2_ = {name:timeNameOrCuePoint};
  131.             break;
  132.          case "number":
  133.             _loc2_ = {time:timeNameOrCuePoint};
  134.             break;
  135.          case "object":
  136.             _loc2_ = timeNameOrCuePoint;
  137.       }
  138.       var _loc3_ = this.getCuePointIndex(this.asCuePoints,false,_loc2_.time,_loc2_.name);
  139.       if(_loc3_ < 0)
  140.       {
  141.          return null;
  142.       }
  143.       _loc2_ = this.asCuePoints[_loc3_];
  144.       this.asCuePoints.splice(_loc3_,1);
  145.       _loc3_ = this.getCuePointIndex(this.allCuePoints,false,_loc2_.time,_loc2_.name);
  146.       if(_loc3_ > 0)
  147.       {
  148.          this.allCuePoints.splice(_loc3_,1);
  149.       }
  150.       if(this._owner.getVideoPlayer(this._id).playheadTime > 0)
  151.       {
  152.          if(this._asCuePointIndex > _loc3_)
  153.          {
  154.             this._asCuePointIndex = this._asCuePointIndex - 1;
  155.          }
  156.       }
  157.       else
  158.       {
  159.          this._asCuePointIndex = 0;
  160.       }
  161.       return _loc2_;
  162.    }
  163.    function setFLVCuePointEnabled(enabled, timeNameOrCuePoint)
  164.    {
  165.       var _loc4_ = undefined;
  166.       switch(typeof timeNameOrCuePoint)
  167.       {
  168.          case "string":
  169.             _loc4_ = {name:timeNameOrCuePoint};
  170.             break;
  171.          case "number":
  172.             _loc4_ = {time:timeNameOrCuePoint};
  173.             break;
  174.          case "object":
  175.             _loc4_ = timeNameOrCuePoint;
  176.       }
  177.       var _loc12_ = isNaN(_loc4_.time) || _loc4_.time < 0;
  178.       var _loc11_ = _loc4_.name == null;
  179.       if(_loc12_ && _loc11_)
  180.       {
  181.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  182.       }
  183.       var _loc6_ = 0;
  184.       var _loc2_ = undefined;
  185.       var _loc5_ = undefined;
  186.       if(_loc12_)
  187.       {
  188.          if(!this._metadataLoaded)
  189.          {
  190.             if(this._disabledCuePointsByNameOnly[_loc4_.name] == null)
  191.             {
  192.                if(!enabled)
  193.                {
  194.                   if(this._disabledCuePointsByNameOnly == null || this._disabledCuePointsByNameOnly.length < 0)
  195.                   {
  196.                      this._disabledCuePointsByNameOnly = new Object();
  197.                   }
  198.                   this._disabledCuePointsByNameOnly[_loc4_.name] = new Array();
  199.                }
  200.                this.removeCuePoints(this._disabledCuePoints,_loc4_);
  201.                return -1;
  202.             }
  203.             if(enabled)
  204.             {
  205.                this._disabledCuePointsByNameOnly[_loc4_.name] = undefined;
  206.             }
  207.             return -1;
  208.          }
  209.          if(enabled)
  210.          {
  211.             _loc6_ = this.removeCuePoints(this._disabledCuePoints,_loc4_);
  212.          }
  213.          else
  214.          {
  215.             var _loc3_ = undefined;
  216.             _loc2_ = this.getCuePointIndex(this.flvCuePoints,true,-1,_loc4_.name);
  217.             while(_loc2_ >= 0)
  218.             {
  219.                _loc3_ = this.flvCuePoints[_loc2_];
  220.                _loc5_ = this.getCuePointIndex(this._disabledCuePoints,true,_loc3_.time);
  221.                if(_loc5_ < 0 || this._disabledCuePoints[_loc5_].time != _loc3_.time)
  222.                {
  223.                   this._disabledCuePoints = this.insertCuePoint(_loc5_,this._disabledCuePoints,{name:_loc3_.name,time:_loc3_.time});
  224.                   _loc6_ += 1;
  225.                }
  226.                _loc2_ = this.getNextCuePointIndexWithName(_loc3_.name,this.flvCuePoints,_loc2_);
  227.             }
  228.          }
  229.          return _loc6_;
  230.       }
  231.       _loc2_ = this.getCuePointIndex(this._disabledCuePoints,false,_loc4_.time,_loc4_.name);
  232.       if(_loc2_ < 0)
  233.       {
  234.          if(enabled)
  235.          {
  236.             if(!this._metadataLoaded)
  237.             {
  238.                _loc2_ = this.getCuePointIndex(this._disabledCuePoints,false,_loc4_.time);
  239.                if(_loc2_ < 0)
  240.                {
  241.                   _loc5_ = this.getCuePointIndex(this._disabledCuePointsByNameOnly[_loc4_.name],true,_loc4_.time);
  242.                   if(mx.video.CuePointManager.cuePointCompare(_loc4_.time,null,this._disabledCuePointsByNameOnly[_loc4_.name]) != 0)
  243.                   {
  244.                      this._disabledCuePointsByNameOnly[_loc4_.name] = this.insertCuePoint(_loc5_,this._disabledCuePointsByNameOnly[_loc4_.name],_loc4_);
  245.                   }
  246.                }
  247.                else
  248.                {
  249.                   this._disabledCuePoints.splice(_loc2_,1);
  250.                }
  251.             }
  252.             return !this._metadataLoaded ? -1 : 0;
  253.          }
  254.          if(this._metadataLoaded)
  255.          {
  256.             _loc2_ = this.getCuePointIndex(this.flvCuePoints,false,_loc4_.time,_loc4_.name);
  257.             if(_loc2_ < 0)
  258.             {
  259.                return 0;
  260.             }
  261.             if(_loc11_)
  262.             {
  263.                _loc4_.name = this.flvCuePoints[_loc2_].name;
  264.             }
  265.          }
  266.          _loc5_ = this.getCuePointIndex(this._disabledCuePoints,true,_loc4_.time);
  267.          this._disabledCuePoints = this.insertCuePoint(_loc5_,this._disabledCuePoints,_loc4_);
  268.          _loc6_ = 1;
  269.          return !this._metadataLoaded ? -1 : _loc6_;
  270.       }
  271.       if(enabled)
  272.       {
  273.          this._disabledCuePoints.splice(_loc2_,1);
  274.          _loc6_ = 1;
  275.       }
  276.       else
  277.       {
  278.          _loc6_ = 0;
  279.       }
  280.       return !this._metadataLoaded ? -1 : _loc6_;
  281.    }
  282.    function removeCuePoints(cuePointArray, cuePoint)
  283.    {
  284.       var _loc2_ = undefined;
  285.       var _loc4_ = undefined;
  286.       var _loc5_ = 0;
  287.       _loc2_ = this.getCuePointIndex(cuePointArray,true,-1,cuePoint.name);
  288.       while(_loc2_ >= 0)
  289.       {
  290.          _loc4_ = cuePointArray[_loc2_];
  291.          cuePointArray.splice(_loc2_,1);
  292.          _loc2_ = _loc2_ - 1;
  293.          _loc5_ = _loc5_ + 1;
  294.          _loc2_ = this.getNextCuePointIndexWithName(_loc4_.name,cuePointArray,_loc2_);
  295.       }
  296.       return _loc5_;
  297.    }
  298.    function insertCuePoint(insertIndex, cuePointArray, cuePoint)
  299.    {
  300.       if(insertIndex < 0)
  301.       {
  302.          cuePointArray = new Array();
  303.          cuePointArray.push(cuePoint);
  304.       }
  305.       else
  306.       {
  307.          if(cuePointArray[insertIndex].time > cuePoint.time)
  308.          {
  309.             insertIndex = 0;
  310.          }
  311.          else
  312.          {
  313.             insertIndex = insertIndex + 1;
  314.          }
  315.          cuePointArray.splice(insertIndex,0,cuePoint);
  316.       }
  317.       return cuePointArray;
  318.    }
  319.    function isFLVCuePointEnabled(timeNameOrCuePoint)
  320.    {
  321.       if(!this._metadataLoaded)
  322.       {
  323.          return true;
  324.       }
  325.       var _loc3_ = undefined;
  326.       switch(typeof timeNameOrCuePoint)
  327.       {
  328.          case "string":
  329.             _loc3_ = {name:timeNameOrCuePoint};
  330.             break;
  331.          case "number":
  332.             _loc3_ = {time:timeNameOrCuePoint};
  333.             break;
  334.          case "object":
  335.             _loc3_ = timeNameOrCuePoint;
  336.       }
  337.       var _loc5_ = isNaN(_loc3_.time) || _loc3_.time < 0;
  338.       var _loc6_ = _loc3_.name == null;
  339.       if(_loc5_ && _loc6_)
  340.       {
  341.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  342.       }
  343.       if(_loc5_)
  344.       {
  345.          var _loc2_ = this.getCuePointIndex(this.flvCuePoints,true,-1,_loc3_.name);
  346.          if(_loc2_ < 0)
  347.          {
  348.             return true;
  349.          }
  350.          while(_loc2_ >= 0)
  351.          {
  352.             if(this.getCuePointIndex(this._disabledCuePoints,false,this.flvCuePoints[_loc2_].time,this.flvCuePoints[_loc2_].name) < 0)
  353.             {
  354.                return true;
  355.             }
  356.             _loc2_ = this.getNextCuePointIndexWithName(_loc3_.name,this.flvCuePoints,_loc2_);
  357.          }
  358.          return false;
  359.       }
  360.       return this.getCuePointIndex(this._disabledCuePoints,false,_loc3_.time,_loc3_.name) < 0;
  361.    }
  362.    function dispatchASCuePoints()
  363.    {
  364.       var _loc5_ = this._owner.getVideoPlayer(this._id).playheadTime;
  365.       if(this._owner.getVideoPlayer(this._id).stateResponsive && this.asCuePoints != null)
  366.       {
  367.          while(this._asCuePointIndex < this.asCuePoints.length && this.asCuePoints[this._asCuePointIndex].time <= _loc5_ + this._asCuePointTolerance)
  368.          {
  369.             this._owner.dispatchEvent({type:"cuePoint",info:mx.video.CuePointManager.deepCopyObject(this.asCuePoints[this._asCuePointIndex++]),vp:this._id});
  370.          }
  371.       }
  372.    }
  373.    function resetASCuePointIndex(time)
  374.    {
  375.       if(time <= 0 || this.asCuePoints == null)
  376.       {
  377.          this._asCuePointIndex = 0;
  378.          return undefined;
  379.       }
  380.       var _loc2_ = this.getCuePointIndex(this.asCuePoints,true,time);
  381.       this._asCuePointIndex = this.asCuePoints[_loc2_].time >= time ? _loc2_ : _loc2_ + 1;
  382.    }
  383.    function processFLVCuePoints(metadataCuePoints)
  384.    {
  385.       this._metadataLoaded = true;
  386.       if(metadataCuePoints == null || metadataCuePoints.length < 1)
  387.       {
  388.          this.flvCuePoints = null;
  389.          this.navCuePoints = null;
  390.          this.eventCuePoints = null;
  391.          return undefined;
  392.       }
  393.       this.flvCuePoints = metadataCuePoints;
  394.       this.navCuePoints = new Array();
  395.       this.eventCuePoints = new Array();
  396.       var _loc5_ = undefined;
  397.       var _loc6_ = -1;
  398.       var _loc2_ = undefined;
  399.       var _loc4_ = this._disabledCuePoints;
  400.       var _loc3_ = 0;
  401.       this._disabledCuePoints = new Array();
  402.       var _loc9_ = 0;
  403.       while((_loc2_ = this.flvCuePoints[_loc9_++]) != null)
  404.       {
  405.          if(_loc6_ > 0 && _loc6_ >= _loc2_.time)
  406.          {
  407.             this.flvCuePoints = null;
  408.             this.navCuePoints = null;
  409.             this.eventCuePoints = null;
  410.             this._disabledCuePoints = null;
  411.             this._disabledCuePointsByNameOnly = null;
  412.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"Unsorted cuePoint found after time: " + _loc6_);
  413.          }
  414.          _loc6_ = _loc2_.time;
  415.          while(_loc3_ < _loc4_.length && mx.video.CuePointManager.cuePointCompare(_loc4_[_loc3_].time,null,_loc2_) < 0)
  416.          {
  417.             _loc3_ = _loc3_ + 1;
  418.          }
  419.          if(this._disabledCuePointsByNameOnly[_loc2_.name] != null || _loc3_ < _loc4_.length && mx.video.CuePointManager.cuePointCompare(_loc4_[_loc3_].time,_loc4_[_loc3_].name,_loc2_) == 0)
  420.          {
  421.             this._disabledCuePoints.push({time:_loc2_.time,name:_loc2_.name});
  422.          }
  423.          if(_loc2_.type == "navigation")
  424.          {
  425.             this.navCuePoints.push(_loc2_);
  426.          }
  427.          else if(_loc2_.type == "event")
  428.          {
  429.             this.eventCuePoints.push(_loc2_);
  430.          }
  431.          if(this.allCuePoints == null || this.allCuePoints.length < 1)
  432.          {
  433.             this.allCuePoints = new Array();
  434.             this.allCuePoints.push(_loc2_);
  435.          }
  436.          else
  437.          {
  438.             _loc5_ = this.getCuePointIndex(this.allCuePoints,true,_loc2_.time);
  439.             _loc5_ = this.allCuePoints[_loc5_].time <= _loc2_.time ? _loc5_ + 1 : 0;
  440.             this.allCuePoints.splice(_loc5_,0,_loc2_);
  441.          }
  442.       }
  443.       delete this._disabledCuePointsByNameOnly;
  444.       this._disabledCuePointsByNameOnly = null;
  445.    }
  446.    function processCuePointsProperty(cuePoints)
  447.    {
  448.       if(cuePoints == null || cuePoints.length == 0)
  449.       {
  450.          return undefined;
  451.       }
  452.       var _loc4_ = 0;
  453.       var _loc8_ = undefined;
  454.       var _loc6_ = undefined;
  455.       var _loc7_ = undefined;
  456.       var _loc5_ = undefined;
  457.       var _loc9_ = undefined;
  458.       var _loc2_ = 0;
  459.       while(_loc2_ < cuePoints.length - 1)
  460.       {
  461.          switch(_loc4_)
  462.          {
  463.             case 6:
  464.                this.addOrDisable(_loc9_,_loc5_);
  465.                _loc4_ = 0;
  466.             case 0:
  467.                if(cuePoints[_loc2_++] != "t")
  468.                {
  469.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  470.                }
  471.                if(isNaN(cuePoints[_loc2_]))
  472.                {
  473.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  474.                }
  475.                _loc5_ = new Object();
  476.                break;
  477.             case 1:
  478.                if(cuePoints[_loc2_++] != "n")
  479.                {
  480.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  481.                }
  482.                if(cuePoints[_loc2_] == null)
  483.                {
  484.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be null or undefined");
  485.                }
  486.                _loc5_.name = this.unescape(cuePoints[_loc2_]);
  487.                _loc4_ = _loc4_ + 1;
  488.                break;
  489.             case 2:
  490.                if(cuePoints[_loc2_++] != "t")
  491.                {
  492.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  493.                }
  494.                if(isNaN(cuePoints[_loc2_]))
  495.                {
  496.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"type must be number");
  497.                }
  498.                switch(cuePoints[_loc2_])
  499.                {
  500.                   case 0:
  501.                      _loc5_.type = "event";
  502.                      break;
  503.                   case 1:
  504.                      _loc5_.type = "navigation";
  505.                      break;
  506.                   case 2:
  507.                      _loc5_.type = "actionscript";
  508.                      break;
  509.                   default:
  510.                      throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"type must be 0, 1 or 2");
  511.                }
  512.                _loc4_ = _loc4_ + 1;
  513.                break;
  514.             case 3:
  515.                if(cuePoints[_loc2_++] != "d")
  516.                {
  517.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  518.                }
  519.                if(isNaN(cuePoints[_loc2_]))
  520.                {
  521.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"disabled must be number");
  522.                }
  523.                _loc9_ = cuePoints[_loc2_] != 0;
  524.                _loc4_ = _loc4_ + 1;
  525.                break;
  526.             case 4:
  527.                if(cuePoints[_loc2_++] != "p")
  528.                {
  529.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  530.                }
  531.                if(isNaN(cuePoints[_loc2_]))
  532.                {
  533.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"num params must be number");
  534.                }
  535.                _loc8_ = cuePoints[_loc2_];
  536.                _loc4_ = _loc4_ + 1;
  537.                if(_loc8_ == 0)
  538.                {
  539.                   _loc4_ = _loc4_ + 1;
  540.                }
  541.                else
  542.                {
  543.                   _loc5_.parameters = new Object();
  544.                }
  545.                break;
  546.             case 5:
  547.                _loc6_ = cuePoints[_loc2_++];
  548.                _loc7_ = cuePoints[_loc2_];
  549.                if(typeof _loc6_ == "string")
  550.                {
  551.                   _loc6_ = this.unescape(_loc6_);
  552.                }
  553.                if(typeof _loc7_ == "string")
  554.                {
  555.                   _loc7_ = this.unescape(_loc7_);
  556.                }
  557.                _loc5_.parameters[_loc6_] = _loc7_;
  558.                _loc8_ = _loc8_ - 1;
  559.                if(_loc8_ == 0)
  560.                {
  561.                   _loc4_ = _loc4_ + 1;
  562.                }
  563.                break;
  564.          }
  565.          _loc5_.time = cuePoints[_loc2_] / 1000;
  566.          _loc4_ = _loc4_ + 1;
  567.          _loc2_ = _loc2_ + 1;
  568.       }
  569.       if(_loc4_ == 6)
  570.       {
  571.          this.addOrDisable(_loc9_,_loc5_);
  572.       }
  573.       throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected end of cuePoint param string");
  574.    }
  575.    function addOrDisable(disable, cuePoint)
  576.    {
  577.       if(disable)
  578.       {
  579.          if(cuePoint.type == "actionscript")
  580.          {
  581.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"Cannot disable actionscript cue points");
  582.          }
  583.          this.setFLVCuePointEnabled(false,cuePoint);
  584.       }
  585.       else if(cuePoint.type == "actionscript")
  586.       {
  587.          this.addASCuePoint(cuePoint);
  588.       }
  589.    }
  590.    function unescape(origStr)
  591.    {
  592.       var _loc3_ = origStr;
  593.       var _loc1_ = 0;
  594.       while(_loc1_ < mx.video.CuePointManager.cuePointsReplace.length)
  595.       {
  596.          var _loc2_ = _loc3_.split(mx.video.CuePointManager.cuePointsReplace[_loc1_++]);
  597.          if(_loc2_.length > 1)
  598.          {
  599.             _loc3_ = _loc2_.join(mx.video.CuePointManager.cuePointsReplace[_loc1_]);
  600.          }
  601.          _loc1_ = _loc1_ + 1;
  602.       }
  603.       return _loc3_;
  604.    }
  605.    function getCuePointIndex(cuePointArray, closeIsOK, time, name, start, len)
  606.    {
  607.       if(cuePointArray == null || cuePointArray.length < 1)
  608.       {
  609.          return -1;
  610.       }
  611.       var _loc13_ = isNaN(time) || time < 0;
  612.       var _loc16_ = name == null;
  613.       if(_loc13_ && _loc16_)
  614.       {
  615.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  616.       }
  617.       if(start == null)
  618.       {
  619.          start = 0;
  620.       }
  621.       if(len == null)
  622.       {
  623.          len = cuePointArray.length;
  624.       }
  625.       if(!_loc16_ && (closeIsOK || _loc13_))
  626.       {
  627.          var _loc8_ = undefined;
  628.          var _loc2_ = undefined;
  629.          if(_loc13_)
  630.          {
  631.             _loc8_ = start;
  632.          }
  633.          else
  634.          {
  635.             _loc8_ = this.getCuePointIndex(cuePointArray,closeIsOK,time);
  636.          }
  637.          _loc2_ = _loc8_;
  638.          while(_loc2_ >= start)
  639.          {
  640.             if(cuePointArray[_loc2_].name == name)
  641.             {
  642.                break;
  643.             }
  644.             _loc2_ = _loc2_ - 1;
  645.          }
  646.          if(_loc2_ >= start)
  647.          {
  648.             return _loc2_;
  649.          }
  650.          _loc2_ = _loc8_ + 1;
  651.          while(_loc2_ < len)
  652.          {
  653.             if(cuePointArray[_loc2_].name == name)
  654.             {
  655.                break;
  656.             }
  657.             _loc2_ = _loc2_ + 1;
  658.          }
  659.          if(_loc2_ < len)
  660.          {
  661.             return _loc2_;
  662.          }
  663.          return -1;
  664.       }
  665.       var _loc6_ = undefined;
  666.       if(len <= this._linearSearchTolerance)
  667.       {
  668.          var _loc11_ = start + len;
  669.          var _loc3_ = start;
  670.          while(_loc3_ < _loc11_)
  671.          {
  672.             _loc6_ = mx.video.CuePointManager.cuePointCompare(time,name,cuePointArray[_loc3_]);
  673.             if(_loc6_ == 0)
  674.             {
  675.                return _loc3_;
  676.             }
  677.             if(_loc6_ < 0)
  678.             {
  679.                break;
  680.             }
  681.             _loc3_ = _loc3_ + 1;
  682.          }
  683.          if(closeIsOK)
  684.          {
  685.             if(_loc3_ > 0)
  686.             {
  687.                return _loc3_ - 1;
  688.             }
  689.             return 0;
  690.          }
  691.          return -1;
  692.       }
  693.       var _loc12_ = Math.floor(len / 2);
  694.       var _loc15_ = start + _loc12_;
  695.       _loc6_ = mx.video.CuePointManager.cuePointCompare(time,name,cuePointArray[_loc15_]);
  696.       if(_loc6_ < 0)
  697.       {
  698.          return this.getCuePointIndex(cuePointArray,closeIsOK,time,name,start,_loc12_);
  699.       }
  700.       if(_loc6_ > 0)
  701.       {
  702.          return this.getCuePointIndex(cuePointArray,closeIsOK,time,name,_loc15_ + 1,_loc12_ - 1 + len % 2);
  703.       }
  704.       return _loc15_;
  705.    }
  706.    function getNextCuePointIndexWithName(name, array, index)
  707.    {
  708.       if(name == null)
  709.       {
  710.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be undefined or null");
  711.       }
  712.       if(array == null)
  713.       {
  714.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint.array undefined");
  715.       }
  716.       if(isNaN(index) || index < -1 || index >= array.length)
  717.       {
  718.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint.index must be number between -1 and cuePoint.array.length");
  719.       }
  720.       var _loc1_ = undefined;
  721.       _loc1_ = index + 1;
  722.       while(_loc1_ < array.length)
  723.       {
  724.          if(array[_loc1_].name == name)
  725.          {
  726.             break;
  727.          }
  728.          _loc1_ = _loc1_ + 1;
  729.       }
  730.       if(_loc1_ < array.length)
  731.       {
  732.          return _loc1_;
  733.       }
  734.       return -1;
  735.    }
  736.    static function cuePointCompare(time, name, cuePoint)
  737.    {
  738.       var _loc1_ = Math.round(time * 1000);
  739.       var _loc2_ = Math.round(cuePoint.time * 1000);
  740.       if(_loc1_ < _loc2_)
  741.       {
  742.          return -1;
  743.       }
  744.       if(_loc1_ > _loc2_)
  745.       {
  746.          return 1;
  747.       }
  748.       if(name != null)
  749.       {
  750.          if(name == cuePoint.name)
  751.          {
  752.             return 0;
  753.          }
  754.          if(name < cuePoint.name)
  755.          {
  756.             return -1;
  757.          }
  758.          return 1;
  759.       }
  760.       return 0;
  761.    }
  762.    function getCuePoint(cuePointArray, closeIsOK, timeNameOrCuePoint)
  763.    {
  764.       var _loc2_ = undefined;
  765.       switch(typeof timeNameOrCuePoint)
  766.       {
  767.          case "string":
  768.             _loc2_ = {name:timeNameOrCuePoint};
  769.             break;
  770.          case "number":
  771.             _loc2_ = {time:timeNameOrCuePoint};
  772.             break;
  773.          case "object":
  774.             _loc2_ = timeNameOrCuePoint;
  775.       }
  776.       var _loc3_ = this.getCuePointIndex(cuePointArray,closeIsOK,_loc2_.time,_loc2_.name);
  777.       if(_loc3_ < 0)
  778.       {
  779.          return null;
  780.       }
  781.       _loc2_ = mx.video.CuePointManager.deepCopyObject(cuePointArray[_loc3_]);
  782.       _loc2_.array = cuePointArray;
  783.       _loc2_.index = _loc3_;
  784.       return _loc2_;
  785.    }
  786.    function getNextCuePointWithName(cuePoint)
  787.    {
  788.       if(cuePoint == null)
  789.       {
  790.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint parameter undefined");
  791.       }
  792.       if(isNaN(cuePoint.time) || cuePoint.time < 0)
  793.       {
  794.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  795.       }
  796.       var _loc3_ = this.getNextCuePointIndexWithName(cuePoint.name,cuePoint.array,cuePoint.index);
  797.       if(_loc3_ < 0)
  798.       {
  799.          return null;
  800.       }
  801.       var _loc4_ = mx.video.CuePointManager.deepCopyObject(cuePoint.array[_loc3_]);
  802.       _loc4_.array = cuePoint.array;
  803.       _loc4_.index = _loc3_;
  804.       return _loc4_;
  805.    }
  806.    static function deepCopyObject(obj, recurseLevel)
  807.    {
  808.       if(obj == null || typeof obj != "object")
  809.       {
  810.          return obj;
  811.       }
  812.       if(recurseLevel == null)
  813.       {
  814.          recurseLevel = 0;
  815.       }
  816.       var _loc2_ = new Object();
  817.       for(var _loc4_ in obj)
  818.       {
  819.          if(!(recurseLevel == 0 && (_loc4_ == "array" || _loc4_ == "index")))
  820.          {
  821.             if(typeof obj[_loc4_] == "object")
  822.             {
  823.                _loc2_[_loc4_] = mx.video.CuePointManager.deepCopyObject(obj[_loc4_],recurseLevel + 1);
  824.             }
  825.             else
  826.             {
  827.                _loc2_[_loc4_] = obj[_loc4_];
  828.             }
  829.          }
  830.       }
  831.       return _loc2_;
  832.    }
  833. }
  834.